]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
portalHelper: Stop using non-default ARGV vector
authorFlorian Müllner <fmuellner@gnome.org>
Tue, 30 May 2023 12:41:36 +0000 (14:41 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Wed, 21 Jun 2023 11:26:42 +0000 (13:26 +0200)
If gjs itself defines ARGV, it only holds the arguments that are
passed on to the script, and javascript code should combine the
programName and ARGV (or the newer programArgs) when it needs a
C-style argv array.

Do the same in the portal-helper process instead of passing along
the original C argv, to avoid confusion when accessing the arguments
from javascript.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2786>

src/gnome-shell-portal-helper.c

index a0bebb216d9db1ea69ee6fba2f2fd70d68ed2d61..9e03a482da02d02b9a5fe212c3dd56627f78bba4 100644 (file)
@@ -18,23 +18,16 @@ main (int argc, char *argv[])
   textdomain (GETTEXT_PACKAGE);
 
   context = g_object_new (GJS_TYPE_CONTEXT,
+                          "program-name", *argv,
                           "search-path", search_path,
                           NULL);
 
-  if (!gjs_context_define_string_array(context, "ARGV",
-                                       argc, (const char**)argv,
-                                       &error))
-    {
-      g_message("Failed to define ARGV: %s", error->message);
-      g_error_free (error);
-      g_object_unref (context);
-
-      return 1;
-    }
-
+  gjs_context_set_argv(context, argc - 1, (const char**)argv + 1);
 
   if (!gjs_context_eval (context,
-                         "const Main = imports.portalHelper.main; Main.main(ARGV);",
+                         "const Main = imports.portalHelper.main;"
+                         "const {programInvocationName, programArgs} = imports.system;"
+                         "Main.main([programInvocationName, ...programArgs]);",
                          -1,
                          "<main>",
                          &status,